package com.zhanggm.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhanggm.entity.User;
import com.zhanggm.service.IUserService;
import org.junit.validator.PublicClassValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author zhanggm
 * @since 2020-05-21
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService iUserService;

    @RequestMapping("list")
    public Object list(User user, ModelMap modelMap,
                @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                @RequestParam(value = "pageSize",defaultValue = "1") Integer pageSize){
        Page<User> pageInfo = (Page<User>) iUserService.getPageInfo(pageNum, pageSize, user);
        modelMap.addAttribute("pageInfo",pageInfo);
        modelMap.addAttribute("pages",pageInfo.getPages());
        return "list";
    }

}
